package com.hjc.springbootmovies.controller;

import com.hjc.springbootmovies.entity.ModelHall;
import com.hjc.springbootmovies.service.Impl.HallServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created by IntelliJ IDEA.
 * User: HJC
 * Date: 2019/12/4
 * Time: 14:34
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("/hall")
public class HallController {
    @Autowired
    private HallServiceImpl hallService;

    @GetMapping("hallControllerAll")
    public String hallAll(){
        return "html/hall/all";
    }

    @GetMapping("hallControllerAdd")
    public String hallAdd(){
        return "html/hall/add";
    }

    @GetMapping("hallControllerUpdate")
    public String hallUpdate(int tid , Model model){
        model.addAttribute("update" , hallService.queryById(tid));
        return "html/hall/update";
    }

    @RequestMapping(value = "addHall" , method = RequestMethod.POST)
    public String addHall(ModelHall modelHall){
        int count = hallService.addHall(modelHall);
        return "html/hall/all";
    }

    @RequestMapping(value = "deleteById" , method = RequestMethod.GET)
    public String deleteById(int tid){
        int count = hallService.deleteById(tid);
        return "html/hall/all";
    }

    @RequestMapping(value = "updateHall" , method = RequestMethod.POST)
    public String updateHall(ModelHall modelHall){
        int count = hallService.updateHall(modelHall);
        return "html/hall/all";
    }
}
